﻿app.directive("ngMatchWithField", function () {
    return {
        require: "ngModel",
        link: function (scope, element, attrs, ctrl) {
            element.bind('keyup', function () {
                var firstPasswordField = '#' + attrs.ngMatchWithField;
                scope.$apply(function () {
                    var isValid = element.val() === $(firstPasswordField).val();
                    ctrl.$setValidity('ngMatchWithField', isValid);
                });
            });
        }
    };
});
app.directive('dateTime', function () {
    return {
        restrict: 'A',
        require: 'ngModel',
        link: function (scope, element, attrs, ngModelCtrl) {
            element.datetimepicker({
                format: "MM-yyyy",
                viewMode: "months",
                minViewMode: "months",
                pickTime: false,
            }).on('changeDate', function (e) {
                ngModelCtrl.$setViewValue(e.date);
                scope.$apply();
            });
        }
    };
});